package jpa;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

	/**
	 * JPA Class OrderdetailJPA
	 */
	@Entity
	@Table(name="practicalcase.orderdetail")
	public class OrderdetailJPA implements Serializable {

		private static final long serialVersionUID = 1L;

		private int id;
		private PetJPA pet;
		private OrderJPA order;
		
	/**
	 * Class constructor methods
	 */
		public OrderdetailJPA() {
			super();
		}
		public OrderdetailJPA( OrderJPA order,int id,PetJPA pet) {
			super();
			this.id = id;
			this.order=order;
			this.pet=pet;
			
		}
		public OrderdetailJPA(int id,PetJPA pet) {
			super();
			this.id = id;
			this.pet=pet;
			
		}

	
		/**
		 *  Methods get/set the fields of database
		 *  Id Primary Key field
		 */
		@Id
		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
		}
		
		/**
		 * Methods get/set persistent relationships
		 */
		@Id
		@ManyToOne
		@JoinColumn (name="idorder")
		public OrderJPA getOrder() {
			return order;
		}
		public  void setOrder(OrderJPA order) {
			this.order = order;
		}

		@OneToOne
		@JoinColumn (name="idpet")
		public PetJPA getPet() {
			return pet;
		}
		public void setPet(PetJPA pet) {
			this.pet = pet;
		}
		@Override
		public String toString() {
			return "OrderdetailJPA [id=" + id + ", pet=" + pet + ", order="
					+ order + "]";
		}
	
	}	